package com.example.multithread;

public class ThreadInterruptedTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            try {
                System.out.println("[" + Thread.currentThread().getName() + "] 准备进入到休眠状态，预计的休眠时间为20秒 ...");
                Thread.sleep(20000);
                System.out.println("["+Thread.currentThread().getName()+"] 休眠状态正常结束 ...");
            } catch (InterruptedException e) {
                System.out.println("["+Thread.currentThread().getName()+"] 休眠产生了一场，无法正常完成休眠处理 ...");
            }
        });
        thread.start();
        System.out.println("[中断状态] " + thread.isInterrupted());
        thread.interrupt();
        Thread.sleep(2000);
        System.out.println("[中断状态] " + thread.isInterrupted());
    }
}
